//
//  UIView+ZYYFrame.m
//  BuDeJie
//
//  Created by Visitor.zs on 15/3/8.
//  Copyright © 2016年  zhangyongyong. All rights reserved.
//

#import "UIView+ZYYFrame.h"

@implementation UIView (ZYYFrame)

/**从xib中加载**/

+ (instancetype)viewFormXib
{
    return [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass(self) owner:nil options:nil] lastObject];
}

// 分类的实现

/********* ----------x--------- *********/
/**
 设置控件的x位置
 */
- (void)setZyy_x:(CGFloat)zyy_x
{
    CGRect frame = self.frame;
    frame.origin.x = zyy_x;
    self.frame = frame;
}
/**
 返回控件的x位置
 */
- (CGFloat)zyy_x
{
    return self.frame.origin.x;
}

/********* ----------y--------- *********/

/**
 设置控件的y位置
 */
- (void)setZyy_y:(CGFloat)zyy_y
{
    CGRect frame = self.frame;
    frame.origin.y = zyy_y;
    self.frame = frame;
}
/**
 返回控件的y位置
 */
- (CGFloat)zyy_y
{
    return self.frame.origin.y;
}

/********* ---------width---------- *********/

/**
 设置控件的width
 */
- (void)setZyy_width:(CGFloat)zyy_width
{
    CGRect frame = self.frame;
    frame.size.width = zyy_width;
    self.frame = frame;
}

/**
 返回控件的width
 */

- (CGFloat)zyy_width
{
    return self.frame.size.width;
}

/********* ----------height--------- *********/

/**
 设置控件的height
 */
- (void)setZyy_height:(CGFloat)zyy_height
{
    CGRect frame = self.frame;
    frame.size.height = zyy_height;
    self.frame = frame;
}
/**
 返回控件的height
 */
- (CGFloat)zyy_height
{
    return self.frame.size.height;
}

/********* ----------center.x--------- *********/

/**
 设置控件的center.x
 */
- (void)setZyy_centerX:(CGFloat)zyy_centerX
{
    CGPoint center = self.center;
    center.x = zyy_centerX;
    self.center = center;
}
/**
 返回控件的zyy_centerX
 */
- (CGFloat)zyy_centerX
{
    return self.center.x;
    
}


/**
 设置控件的center.Y
 */
- (void)setZyy_centerY:(CGFloat)zyy_centerY
{
    CGPoint center = self.center;
    center.y = zyy_centerY;
    self.center = center;
}
/**
 返回控件的center.y
 */
- (CGFloat)zyy_centerY
{
    return self.center.y;
    
}

- (CGFloat)zyy_right
{
    return self.zyy_x + self.zyy_width;
    
}
- (CGFloat)zyy_botton
{
    return self.zyy_y + self.zyy_height;
}

- (void)setZyy_right:(CGFloat)zyy_right
{
    self.zyy_x = zyy_right -self.zyy_width;
}

- (void)setZyy_botton:(CGFloat)zyy_botton
{
    self.zyy_y = zyy_botton - self.zyy_height;
}

@end
